import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from mysql_use import mysqlUse

class onlineExerciseMain:
    # def __init__(self,user_id):
    def __init__(self):
        super().__init__()
        self.db = mysqlUse()
        # self.user_id=user_id

    def generate_exercise0(self,difficulty_type,expression_quantity):
        """随机获取算式，生成一套习题，由此生成一套练习记录"""
        difficulty_type=int(difficulty_type)
        expression_quantity=int(expression_quantity)
        limit_time = expression_quantity * difficulty_type * 20  # 单位s
        #算式获取
        rows=self.db.Obtain_the_difficulty_calculations(difficulty_type,expression_quantity)
        print(rows)
        #习题生成
        # new_exer_id=self.db.add_exercise(difficulty_type, 1, limit_time, expression_quantity)
        # print(new_calc_id)
        new_exer_id=4
        #习题与算式匹配
        # for row_data in rows:
        #     print(int(row_data[0]))
        #     self.db.add_matches(new_exer_id,int(row_data[0]))
        # 练习表中增加数据
        # self.db.add_practice(self.user_id, new_exer_id)
        # self.db.add_practice(1, new_exer_id)
        print("%%%%%%%%%%")
        print(len(rows))
        return rows


        #数据库
        #先生成一套习题，检索算式表对应难度的题，
        # 然后随机取相应数量的题，
        # 将一道道算式匹配刚刚生成的习题
        #给这套题计算限时时长
        #练习表中增加一条数据
        # 界面显示
        #计算习题页面数量
    # def generate_exercise1(self,difficulty_type,expression_quantity,bracket_quantity):
    #     print(difficulty_type)
    #     print(expression_quantity)
    #     print(bracket_quantity)

# onlineExerciseMain().generate_exercise0(1,10)

